<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const p1 = new Promise((resolve, reject) => {
            try {
                console.log('请求A数据。。。');
                throw new Error('A错误')
                setTimeout(() => {
                    console.log('请求A数据结束。。。');
                    resolve("A数据")
                }, 1500)

            } catch (e) {
                reject(e.message)
            }
        })
        const p2 = new Promise((resolve, reject) => {
            try {
                console.log('请求B数据。。。');
                throw new Error('B错误')
                setTimeout(() => {
                    console.log('请求b数据结束。。。');
                    resolve("B数据")
                }, 2500)

            } catch (e) {
                reject(e.message)
            }
        })
                    
        const p3 = new Promise((resolve, reject) => {
            try {

                console.log('请求C数据。。。');
                throw new Error('C错误')
                setTimeout(() => {
                    console.log('请求c数据结束。。。');
                    resolve("C数据")
                }, 3000)

            } catch (e) {
                reject(e.message)
            }
        })
     /* 
      Promise.any方法:
         监听promise实例中最快成功的那个
         any返回的promise实例和最快成功的保持一致
         如果所有的promise全部失败,则返回rejected状态的promise实例,
         值为新的错误:AggregateError: All promises were rejected
    */
        const result = Promise.any([p1, p2, p3]);
        console.log("result", result);
    </script>
</body>
</html>